package asteroids.model.programs.Statement;

import java.util.List;

import asteroids.model.programs.Program;

/**
* 
* @version 0.3
* @author  Tandan Sunil, Van Deun Luca
*
*/
public class SequenceLiteral extends LargeStatement {

	public SequenceLiteral(int line, int column,List<Statement> statements) {
		super(line, column);
		if(statements==null)
			throw new IllegalArgumentException();
		this.statements = statements;
	}

	private List<Statement> statements;
	
	public List<Statement> getStatements(){
		return statements;
	}
	
	
	@Override
	public void execute(Program program) {
		for(Statement s: getStatements()){
			if(!s.isExecuted()){
				s.execute(program);
				if(!s.isExecuted()){
					return;
				}
			}
		}
		boolean allrun = true;
		for(Statement s: getStatements())
			if(!s.isExecuted()){
				allrun=false;
				return;
			}
		if(allrun)
			setExecuted(true);
	}
	
	@Override
	public void setExecuted(boolean executed){
	super.setExecuted(executed);
	for(Statement s:getStatements())
		s.setExecuted(executed);
	}
}
